var url = window.location.href;
var is_local = (url.substring(0,4) == 'file');
// is_local = false;
$(function () { 
  var content = [
    {
      date: "2020-10-01",
      title: "内部测试已开始",
      details: [
        "放假了。"
      ]
    },
    {
      date: "2020-09-04",
      title: "成功部署网页",
      details : [
        "爬，还要不要做mod了？"
      ]
    },

    {
      date: "2020-08-25",
      title: "又是不想做mod的一天，干脆写个网页吧",
      details: [
        "没几天就开学了，老王还搁这儿摸鱼。",
      ]
    },
  ];
  var today = new Date();
  function getUpdateTime(date){
    var days = today - new Date(date);
    return Math.floor(days/86400000);
  }

  var root = $("#detailroot");
  $.each(content, function(i, v){
    var uptime = getUpdateTime(v.date);
    if (uptime == 0){
      uptime = "今天";
    }
    else if (uptime <= 7){
      uptime = uptime + "天前";
    }
    else {
      uptime = v.date;
    }
    root.append("<br><br><p><strong>"+uptime+"</strong>"
      +"<span style='color:grey;'>" +(v.title ? ("&nbsp;-&nbsp;"+v.title) : '')+"</span>"+"</p>");

    $.each(v.details, function(i, text){
      root.append("<p>"+(i+1)+". " + text+"</p>");
    })

  })

  if (!is_local) {
    $("div.alert").hide()
  }

  // lang
  
  // console.log($('lang'))
  // $("lang").click(function(){
  //   console.log("bt");
  // })
})